from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User


# 定义一个继承自UserCreationForm的SignUpForm类，用于用户注册
class SignUpForm(UserCreationForm):
    # 添加email字段，要求输入必填，使用EmailInput控件以增强用户体验
    email = forms.EmailField(max_length=254, required=True, widget=forms.EmailInput())

    # 定义内部类Meta，用于指定模型和表单字段
    class Meta:
        model = User  # 关联的模型类
        fields = ('username', 'email', 'password1', 'password2')  # 指定表单中包含的字段
